<?php

namespace App\Admin\Actions\User;

use App\Models\User;
use Dcat\Admin\Actions\Response;
use Dcat\Admin\Grid\RowAction;

class LockUser extends RowAction
{
    protected string $title = '锁定用户';

    public function handle(): Response
    {
        $user = User::ofAdmin()->find($this->getKey());
        $user->lock = !$user->lock;
        $user->save();

        return $this->response()->success('操作成功')->refresh();
    }

    public function confirm(): array
    {
        return [
            '锁定/解锁 用户',
            '用户锁定后，将无法点赞，评论，助力',
        ];
    }
}
